package com.miao.font.web.controller;


import com.miao.font.entity.Item;
import com.miao.font.entity.TbItem;
import com.miao.font.entity.TbItemDesc;
import com.miao.font.web.httpclient.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author shuangshuang
 * @since 2018-09-19
 */

@RequestMapping("/item")
@Controller
public class TbItemController {

    @Autowired
    private ItemService itemService;
    /**
     * 查询商品详情
     * @param
     * @return
     */
    @RequestMapping(value = "{itemId}",method =RequestMethod.GET )
    public ModelAndView itemDetail(@PathVariable("itemId")Long id){
       ModelAndView mv=new ModelAndView("font/item");
        Item tbItem = itemService.queryById(id);
        //设置模型数据
        mv.addObject("item",tbItem);

        //设置商品描述数据
        TbItemDesc tbItemDesc = itemService.qeruyDescByItemId(id);
        mv.addObject("itemDesc",tbItemDesc);


        //显示规格参数数据
        String itemParam= itemService.queryItemParamItemById(id);
        mv.addObject("itemParam",itemParam);
        return mv;
    }
}

